package springboot.app.web;

import javax.annotation.Resource ;

import org.apache.activemq.command.ActiveMQQueue ;
import org.apache.activemq.command.ActiveMQTopic ;
import org.springframework.web.bind.annotation.GetMapping ;
import org.springframework.web.bind.annotation.PathVariable ;
import org.springframework.web.bind.annotation.RestController ;

import springboot.activeMQ.MsgProducerPub_Sub ;
import springboot.activeMQ.MsgProducer_P2P ;

/**
 * @author 80002165 @date 2017年7月13日 下午3:00:27
 */
@RestController
public class ActiveMQController {
    @Resource
    MsgProducer_P2P msgProducer ;
    
    @Resource
    MsgProducerPub_Sub msgProducerPub_Sub ;
    
    @GetMapping("/test/activemq/send/{msg}/{distince}")
    public String sendMessage(@PathVariable("msg")String msg, @PathVariable("distince")String distince){
        msgProducer.sendMsg(msg);
        msgProducer.sendMsg(new ActiveMQQueue(distince), msg);
        return msg ;
    }
    
    @GetMapping("/test/activemq/send2/{msg}/{distince}")
    public String send2Message(@PathVariable("msg")String msg, @PathVariable("distince")String distince){
        msgProducerPub_Sub.sendMsg(msg);
        msgProducerPub_Sub.sendMsg(new ActiveMQTopic(distince), msg);
        return msg ;
    }
}
